home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / elv18src.zip / instman.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1993-08-15  |  4KB  |  158 lines

  1. #!/bin/sh
  2. #
  3. # This shell script is used on UNIX-like systems to install man-pages.
  4. # It is run automatically during "make install".
  5. #
  6. #   usage: sh install.sh {program names}
  7. #
  8. ################################################################################
  9.  
  10. # This is a list of directories where the nroff source for man-pages might
  11. # be installed.  The order is important -- the man-pages will be installed
  12. # in the first existing directory in the list.
  13. MANDIRS="/usr/man/man.l /usr/man/man.LOCAL /usr/man/man.1 /usr/man/1
  14. /usr/catman.C /usr/man/manl /usr/man/man1"
  15.  
  16. # Similarly, this is a list of directories where the plaintext form of the
  17. # man-pages might belong.  If, after searching, it is decided that both forms
  18. # should go in the same directory, then only the plain-text version is
  19. # installed.
  20. DOCDIRS="/usr/man/catmanl /usr/man/catman.l /usr/man/catman.LOCAL
  21. /usr/man/cat.LOCAL /usr/man/catman.1 /usr/man/cat.C /usr/catman.C
  22. /usr/catman/1 /usr/man/1 /usr/man/cat1"
  23.  
  24. ################################################################################
  25.  
  26. # Complain if no programs were named on the command line
  27. if test $# -lt 1
  28. then
  29.     echo "Usage: sh instman.sh {program names...}"
  30.     echo "     where {program names...} is a list of programs whose"
  31.     echo "     manual pages are to be installed.  It is assumed that"
  32.     echo "     the manual pages are currently located inside the 'doc'"
  33.     echo "     subdirectory."
  34.     echo
  35.     echo "     Note: Normally, this script is executed via 'make install'"
  36.     exit 1
  37. fi
  38.  
  39. # The installed manpages should be readable by everybody, but writable only
  40. # by us.
  41. umask 022
  42.  
  43. # Decide where to put the nroff source docs
  44. mandir=`for dir in $MANDIRS
  45.     do
  46.         if test -d $dir
  47.         then
  48.             echo $dir
  49.             exit 0
  50.         fi
  51.     done`
  52. anydir=$mandir
  53.  
  54. # Decide where to put the plaintext docs
  55. docdir=`for dir in $DOCDIRS
  56.     do
  57.         if test -d $dir
  58.         then
  59.             echo $dir
  60.             exit 0
  61.         fi
  62.     done`
  63. if test "$docdir"
  64. then
  65.     anydir=$docdir
  66. fi
  67.  
  68. # If we didn't find a directory for either of them, then complain & quit
  69. if test -z "$anydir"
  70. then
  71.     echo "::: I CAN'T AUTOMATICALLY INSTALL THE MAN PAGES ON THIS SYSTEM"
  72.     echo "::: BECAUSE I DON'T KNOW WHERE TO PUT THEM!  YOU CAN EITHER"
  73.     echo "::: TRY EDITING THE "instman.sh" SCRIPT & RERUNNING IT, OR"
  74.     echo "::: SIMPLY INSTALL THEM YOURSELF BY HAND."
  75.     exit 1
  76. fi
  77.  
  78. # If they're the same, then we only want to install the plaintext versions
  79. if test "$mandir" = "$docdir"
  80. then
  81.     mandir=
  82. fi
  83.  
  84. # Choose the installed filename extension by looking at the name of the
  85. # directory we'll be installing it into.
  86. case "$anydir" in
  87.   *.LOCAL)    ext=.LOCAL    ;;
  88.   *.L)        ext=.L        ;;
  89.   *l)        ext=.l        ;;
  90.   *1)        ext=.1        ;;
  91.   *)        ext=        ;;
  92. esac
  93.  
  94. # If we're going to be installing the nroff source, then do it now
  95. if test "$mandir"
  96. then
  97.     for i
  98.     do
  99.         cp doc/$i.man $mandir/$i$ext
  100.     done
  101. fi
  102.  
  103. # Sleep briefly, to ensure that the plaintext versions of the files will
  104. # be installed with a newer timestamp than the nroff versions.
  105. sleep 1
  106.  
  107. # If we're going to be installing the plaintext pages, then do it now
  108. if test "$docdir"
  109. then
  110.     for i
  111.     do
  112.         cp doc/$i.doc $docdir/$i$ext
  113.     done
  114. fi
  115.  
  116. # Are man pages sometimes compressed or packed on this system?  If so,
  117. # then give these new pages the same treatment.
  118. for dir in $mandir $docdir
  119. do
  120.     if test "`echo $dir/*.Z`" != "$dir/*.Z"
  121.     then
  122.         for i
  123.         do
  124.             rm -f $dir/$i$ext.Z
  125.             compress $dir/$i$ext
  126.         done
  127.         finalext=$ext.Z
  128.     elif test "`echo $dir/*.z`" != "$dir/*.z"
  129.     then
  130.         for i
  131.         do
  132.             rm -f $dir/$i$ext.z
  133.             pack $dir/$i$ext
  134.         done
  135.         finalext=$ext.z
  136.     elif test "`echo $dir/*.gz`" != "$dir/*.gz"
  137.     then
  138.         for i
  139.         do
  140.             rm -f $dir/$i$ext.z
  141.             gzip $dir/$i$ext
  142.         done
  143.         finalext=$ext.gz
  144.     else
  145.         finalext=$ext
  146.     fi
  147. done
  148.  
  149. # Say what was done
  150. if test "$mandir"
  151. then
  152.     echo "nroffable manpages installed as $mandir/progname$finalext"
  153. fi
  154. if test "$docdir"
  155. then
  156.     echo "plaintext manpages installed as $docdir/progname$finalext"
  157. fi
  158.